﻿Public Class StatusForm

    Private Sub StatusForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim ct As New wys.util.Util.ConUtil(MyConfig.连接字符串)

        txtCon.Text = ct.DataSource

        txtDb.Text = ct.DataBase

        txtUser.Text = ct.User

        txtPwd.Text = ct.Pwd

        '查询添加的表
        Dim Sql As String = "select name,object_id from sys.tables"
        Dim dt表 As DataTable = IListenDb.CommonConUtil.GetTable(Sql)
        For index As Integer = 0 To dt表.Rows.Count - 1
            If dt表.Rows(index)("name").ToString.ToLower.StartsWith(MyConfig.前缀.ToLower) OrElse _
               dt表.Rows(index)("name").ToString.ToLower.StartsWith("t_" & MyConfig.前缀.ToLower) Then
                dg表.Rows.Add(New Object() {dt表.Rows(index)("name")})
            End If
        Next

        '查询添加的触发器
        Sql = "select name,object_id from sys.triggers"
        Dim dt触发器 As DataTable = IListenDb.CommonConUtil.GetTable(Sql)
        For index As Integer = 0 To dt触发器.Rows.Count - 1
            If dt触发器.Rows(index)("name").ToString.ToLower.StartsWith(MyConfig.前缀.ToLower) Then
                dg触发器.Rows.Add(New Object() {dt触发器.Rows(index)("name")})
            End If
        Next

        '查询添加的存储过程
        Sql = "select name,object_id from sys.procedures"
        Dim dt存储过程 As DataTable = IListenDb.CommonConUtil.GetTable(Sql)
        For index As Integer = 0 To dt存储过程.Rows.Count - 1
            If dt存储过程.Rows(index)("name").ToString.ToLower.StartsWith(MyConfig.前缀.ToLower) Then
                dg存储过程.Rows.Add(New Object() {dt存储过程.Rows(index)("name")})
            End If
        Next

        '查询添加的存储过程
        lblStatus.Text = "共添加" & dg表.Rows.Count & "个表" & vbNewLine & "  添加" & dg触发器.Rows.Count & "个触发器" & vbNewLine & "  添加" & dg存储过程.Rows.Count & "个存储过程"
    End Sub

End Class
